import java.util.ArrayList;

import _Banque.*;
import _Exception.BUException;
import _Exception.IPException;
import _Tests.Tests;

public class TI_Banque_N3 {

	public static void main(String[] args) throws IPException, BUException {
		
		Tests.Begin("Integration du package _Banque", "1.0.0");
		
		Banque B1= new Banque("S2D","12345", "IUT Info", "01234567891011");
		B1.creerRegion("PACA");
		B1.creerRegion("AM");
		B1.creerRegion("Var");
		int A1= B1.ouvrirAgence("PACA", "19 Rue Soleau");
		int A2= B1.ouvrirAgence("AM", "13 de Coeur");
		int A3= B1.ouvrirAgence("AM", "20 Avenue des Champs");
		int A4= B1.ouvrirAgence("Var", "No Way");
		int A5= B1.ouvrirAgence("Var", "14 de la Roue");
		Titulaire Dorian= new Titulaire("Lizarralde", "Dorian", "1920/09/22", "Ici");
		Titulaire Loic= new Titulaire("Vial", "Loic", "2008/02/21", "L�");
		Titulaire Julien= new Titulaire("Colin", "Julien", "2007/10/09", "Ou");
		Titulaire Nicolas= new Titulaire("Nagy", "Nicolas", "2006/09/25", "L�-bas");
		Titulaire Edouard= new Titulaire("Oger", "Edouard", "2005/12/30", "Infini");
		Titulaire Valentin= new Titulaire("Pruliere", "Valentin", "2004/12/17", "Et");
		Titulaire Quentin= new Titulaire("Salmeron", "Quentin", "2003/04/07", "Au-del�");
		long L1= B1.getAgence(A1).ouvrirCompte(Dorian);
		long L2= B1.getAgence(A1).ouvrirCompte(Dorian, 0.015f);
		long L3= B1.getAgence(A1).ouvrirCompte(Loic);
		long L4= B1.getAgence(A2).ouvrirCompte(Julien, 0.0035f);
		long L5= B1.getAgence(A2).ouvrirCompte(Nicolas);
		long L6= B1.getAgence(A3).ouvrirCompte(Edouard, 0.0055f);
		long L7= B1.getAgence(A3).ouvrirCompte(Edouard);
		long L8= B1.getAgence(A4).ouvrirCompte(Valentin);
		long L9= B1.getAgence(A5).ouvrirCompte(Quentin);
		long L0= B1.getAgence(A5).ouvrirCompte(Quentin, 0.0015f);
		B1.getAgence(A1).executer(L1, 'V', "Cheque n�1234", 100f);
		B1.getAgence(A1).executer(L2, 'V', "Cheque n�1321", 780f);
		B1.getAgence(A1).executer(L3, 'V', "Cheque n�1684", 200f);
		B1.getAgence(A2).executer(L4, 'V', "Cheque n�1354", 548f);
		B1.getAgence(A2).executer(L5, 'V', "Cheque n�1971", 231f);
		B1.getAgence(A3).executer(L6, 'V', "Cheque n�8165", 516f);
		B1.getAgence(A3).executer(L7, 'V', "Cheque n�7811", 165f);
		B1.getAgence(A4).executer(L8, 'V', "Cheque n�9875", 654f);
		B1.getAgence(A5).executer(L9, 'V', "Cheque n�9832", 160f);
		B1.getAgence(A5).executer(L0, 'V', "Cheque n�4579", 465f);
		
		Tests.Design("Changement de status social de la banque", 3);
		{
			Tests.Case("Changement de status social");
			{
				Banque B2= new Banque("S3D","48651", "IUT Info", "01234567891011");
				
				Tests.Unit(true, B1.equals(B2));
				
				B2.creerRegion("PACA");
				B2.creerRegion("AM");
				B2.creerRegion("Var");
				int O1= B2.ouvrirAgence("PACA", "19 Rue Soleau");
				int O2= B2.ouvrirAgence("AM", "13 de Coeur");
				int O3= B2.ouvrirAgence("AM", "20 Avenue des Champs");
				int O4= B2.ouvrirAgence("Var", "No Way");
				int O5= B2.ouvrirAgence("Var", "14 de la Roue");
				
				B1.getAgence(A1).transferer(B2.getAgence(O1));
				B1.getAgence(A2).transferer(B2.getAgence(O2));
				B1.getAgence(A3).transferer(B2.getAgence(O3));
				B1.getAgence(A4).transferer(B2.getAgence(O4));
				B1.getAgence(A5).transferer(B2.getAgence(O5));
				try {B1.getAgence(A1).transferer(B2.getAgence(12));}
				catch(IPException e) {Tests.Unit(new IPException("aucune agence bancaire ne possede ce numero de guichet"), e);}
				
				B1= null;
				
				Tests.Unit("S3D - Code : 48651\nIUT Info\nSIRET : 01234567891011", B2.toString());

				ArrayList<Long> C1= B2.comptesClient(Dorian);
				ArrayList<Long> C2= B2.comptesClient(Valentin);
				ArrayList<Long> C3= B2.comptesClient(Loic);
				ArrayList<Long> C4= B2.comptesClient(Edouard);				

				ArrayList<Long> S1= new ArrayList<Long>();
				ArrayList<Long> S2= new ArrayList<Long>();
				ArrayList<Long> S3= new ArrayList<Long>();
				ArrayList<Long> S4= new ArrayList<Long>();
				S1.add(L1);
				S1.add(L2);
				S2.add(L8);
				S3.add(L3);
				S4.add(L7);
				S4.add(L6);
				
				Tests.Unit(S1, C1);
				Tests.Unit(S2, C2);
				Tests.Unit(S3, C3);
				Tests.Unit(S4, C4);			
			}
		}		
		Tests.End();
	}

}
